// const repl = require('repl')

// const local = repl.start('$ ')

// local.on('exit', () => {
//   console.log('退出REPL')
//   process.exit(1)
// })

// const oranges = ['orange', 'orange']
// const apples = ['just one apple']
// oranges.forEach(fruit => {
//   console.count(fruit)
// })
// apples.forEach(fruit => {
//   console.count(fruit)
// })
// console.countReset('orange')
// oranges.forEach(fruit => {
//   console.count(fruit)
// })

const doSomeTing = () => {
  console.log('test')
}

const measureDoSomeTing = () => {
  console.time('doSomeTing')
  doSomeTing()
  console.timeEnd('doSomeTing')
}

// measureDoSomeTing()

// console.log('\x1b[33m%s\x1b[0m', 'hi!')
// chalk 是一个颜色库 https://www.npmjs.com/package/chalk
// const chalk = require('chalk')

// console.log(chalk.yellow('hi!'))

// 进度条库 https://www.npmjs.com/package/progress
// const ProgressBar = require('progress')
// const bar = new ProgressBar(':bar', { total: 10 })

// const timer = setInterval(() => {
//   bar.tick()
//   if (bar.complete) {
//     clearInterval(timer)
//   }
// }, 100)

// const readline = require('readline').createInterface({
//   input: process.stdin,
//   output: process.stdout
// })

// readline.question(`What's your name?`, name => {
//   console.log(`Hi ${name}!`)
//   readline.close()
// })

const { prompt } = require('inquirer')

const questions = [{ type: 'input', name: 'name', message: "What's your name?" }]

prompt(questions).then(answers => {
  console.log(`Hi ${answers.name}!`)
})
